package com.guli.staservice.schedule;

import com.guli.staservice.service.StatisticsDailyService;
import com.guli.staservice.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @ClassName: ScheduledTask 
 * @Description: TODO 每天自动生成前一天的统计数据
 * @author: liuzg
 * @Date: 2021/4/1 13:13
 * @Version: v1.0
 */
@Component
public class ScheduledTask {

    @Autowired
    private StatisticsDailyService staService;



    //在 每天凌晨1点，把前一天数据进行数据查询添加
    @Scheduled(cron = "0 0 1 * * ?") // Springboot 整合Scheduled 的时候，cron只能是6位(否则会报错)，最后一位，默认为当年
    public void task2_createRegisterCount() {
        staService.registerCount(DateUtil.formatDate(DateUtil.addDays(new Date(), -1)));
    }



}
